﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simple.Common.Extensions;
using Simple.Repository.Models.Attendance;

namespace Simple.Services.System.Recipes.Models
{
    public class RecipesModel : ModelBase
    {
        public Guid Id { get; set; }

        /// <summary>
        /// 食谱名称
        /// </summary>
        [Required(ErrorMessage = "食谱名称是必输的")]
        public string? RecipeName { get; set; }

        /// <summary>
        /// 食谱简称
        /// </summary> 
        public string? Abbreviation { get; set; }

        public List<RecipesDetailsModel>? RecipesDetailsList { get; set; }

        public override void ConfigureMapper(Profile profile)
        {
            profile.CreateMap<RecipesModel, Simple.Repository.Models.Recipes>();

            profile.CreateMap<Simple.Repository.Models.Recipes, RecipesModel>();

            profile.CreateMap<RecipesDetailsModel, RecipesDetails>();
            profile.CreateMap<RecipesDetails, RecipesDetailsModel>();

        }
    }

    public class RecipesDetailsModel : ModelBase
    {
        public Guid? Id { get; set; }

        public Guid RecipesId { get; set; }

        /// <summary>
        /// 食物重量
        /// </summary>
        public decimal Weight { get; set; }

        /// <summary>
        /// 食材id
        /// </summary>
        public Guid FoodMaterialsId { get; set; }

        /// <summary>
        /// 食材名称
        /// </summary>
        public string FoodName { get; set; }


        /// <summary>
        /// 需求量（斤）
        /// </summary>
        public decimal QuantityRequired { get; set; }


        public override void ConfigureMapper(Profile profile)
        {
            profile.CreateMap<RecipesDetails, RecipesDetailsModel>()
                 .ForMember(c => c.FoodName, option => option.MapFrom(p => p.FoodMaterials.FoodName));
        }

    }

    public class RecipesFoodViewModel : ModelBase
    {
        public Guid Id { get; set; }

        public Guid RecipesId { get; set; }

        /// <summary>
        /// 食物重量
        /// </summary>
        public decimal Weight { get; set; }

        public FoodMaterialsViewModel FoodMaterials { get; set; }

        public override void ConfigureMapper(Profile profile)
        {
            profile.CreateMap<FoodMaterialsViewModel, FoodMaterials>();

            profile.CreateMap<FoodMaterials, FoodMaterialsViewModel>();
        }
    }

    public class FoodMaterialsViewModel
    {
        public Guid Id { get; set; }

        /// <summary>
        /// 食物名称
        /// </summary>
        public string FoodName { get; set; }

        /// <summary>
        /// 食部
        /// </summary>
        public decimal FoodDepartment { get; set; }

        /// <summary>
        /// 热量
        /// </summary>
        public decimal Heat { get; set; }

        /// <summary>
        /// 蛋白质
        /// </summary>
        public decimal Protein { get; set; }

        /// <summary>
        /// 脂肪
        /// </summary>
        public decimal Fat { get; set; }

        /// <summary>
        /// 碳水化合物
        /// </summary>
        public decimal Carbohydrate { get; set; }

        /// <summary>
        /// 钙
        /// </summary>
        public decimal Calcium { get; set; }
        /// <summary>
        /// 铁
        /// </summary>
        public decimal Iron { get; set; }
        /// <summary>
        /// 锌
        /// </summary>
        public decimal Zinc { get; set; }

        /// <summary>
        /// VitA
        /// </summary>
        public decimal VitA { get; set; }
        /// <summary>
        /// VitB1
        /// </summary>
        public decimal VitB1 { get; set; }
        /// <summary>
        /// VitB2
        /// </summary>
        public decimal VitB2 { get; set; }
        /// <summary>
        /// VitC
        /// </summary>
        public decimal VitC { get; set; }

        public Guid FoodMaterialsTypeId { get; set; }

    }


}
